#include <iostream>
#include <vector>
using namespace std;

int count = 10;
void print();
class Test
{
public:
    static inline auto m_name = "zhangsan";
};
//auto Test:: m_name = "zhangsan";
//按值传递  按地址传递  按引用传递

int test(int &&temp)
{
    cout << "&&:" << temp << endl;
    return 0;
}

#if 0
template <typename T>
//void func(T t)  //按值传递:变量丢cv属性，指针保存cv,引用丢弃并丢cv属性
//void func(T *t) //按指针传递：保存cv属性
//void func(T &t) //按引用传递：保存变量和引用的cv属性
void func(T &&t) //万能引用（未定义引用）: 保存cv属性
//引用折叠：&& && ---&&   & &&--&
{
    //test(std::move(t));
    test(std::forward<int &&>(t));
}
#endif

auto func(auto t) 
{
    cout << "t = " << t << endl;
    return t;
}


int main(int argc, char **argv)
{
    int num = 10;
    const int count = 20;
    int *p = &num;
    const int *pcount = &count;

    int &lnum = num;
    const int &lcount = count;
     
    auto pnum = num;
    auto index = count;
    auto p2 = p;
    auto p3 = pcount;
    auto &l1 = lnum;
    auto &l2 = lcount;

    // decltype(num++) pnum2;
    // decltype(test(5)) pnum3;
    // cout << num << endl;

    decltype(num) pnum2;
    decltype(count) dcount = 10;
    decltype(lnum) dlnum = num;
    decltype(lcount) dlcount = count; //cv
    decltype(p) dp;
    decltype(*p) dp2 = num; //左值引用

    decltype(num++) pnum3;
    decltype(++num) pnum4 = num;  
    
    vector<int> vi = {1,2,3,4,5,6,7};
    decltype(vi.begin()) it = vi.begin(); 
    //decltype(vector<int>::iterator)

    func(10);
    func(num); // int  :   T -->int
    func(count); //const int;  T--->?
    func(p);//int *:  T -->int *
    func(pcount);//const int * T-->? 
    func(lnum);
    func(lcount);   

    //print();

    return 0;
}